package beastick.utility;

//Copyright 2008 Tofig Kareemov, estereos@gmail.com
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

import java.io.File;

public class CDateSortedFile implements Comparable{

	  public final static int SORTED_LIST_FILE_NONE	=1;
	  public final static int SORTED_LIST_FILE_ASCENDING	=2;
	  public final static int SORTED_LIST_FILE_DESCENDING	=3;
	
	private File myFile = null;
	private int sortDirection = SORTED_LIST_FILE_ASCENDING;
	public CDateSortedFile(String fileName,int sortDirection) {
		myFile = new File(fileName);
		this.sortDirection = sortDirection;
	}
	public int compareTo(Object file) {
		Long me = new Long(myFile.lastModified());
		Long him = new Long(((CDateSortedFile)file).getMyFile().lastModified());
		if(this.sortDirection==SORTED_LIST_FILE_ASCENDING)
		{
			return him.compareTo(me);	
		}else
		{
			return me.compareTo(him);
		}
	}
	public File getMyFile() {
		return myFile;
	}
	public String getName() {
		return myFile.getName();
	}
	public String getPath() {
		return myFile.getPath();
	}
	public long lastModified() {
		return myFile.lastModified();
	}
	public boolean exists() {
		return myFile.exists();
	}

	public String [] list() {
		return myFile.list();
	}

	public boolean isDirectory() {
	
		return myFile.isDirectory();
	}
	public String getAbsolutePath() {
		return myFile.getAbsolutePath();
	}
	
}
